package kyssion.leetcode.num151_200;

public class code171_Excel表序列号 {

    public static void main(String[] args) {
        System.out.println(new code171_Excel表序列号().titleToNumber(
                "ZY"
        ));
    }

    /**
     * all = 26*(26*(26*(a+1)+b+1)+c+1)+d+1
     *
     * @param s
     * @return
     */
    public int titleToNumber(String s) {
        int all = 0;
        for (int a = 0; a < s.length(); a++) {
            all = all * 26 + (s.charAt(a) - 'A' + 1);
        }
        return all;
    }
}
